// pages/address/address.js
import {toAddress,delAddress} from '../../utils/interface'
Page({
  data:{
    address:[]
  },
  onLoad(){
    this.getAddress()
  },
  async getAddress(){
    let token = wx.getStorageSync('token')
    let {data:res} = await toAddress({token}).catch(err=>err)
    // console.log(res);
    this.setData({
      address:res.data
    })
    console.log(this.data.address,'address');
  },
  async delAddress(e){
    // console.log(e);
    let id =e.currentTarget.dataset.id
    let token =wx.getStorageSync('token')
    let {data:res} = await delAddress({token:token, id:id})
    console.log(res,'删除地址')
    this.getAddress();
  },
  addCity(){
    wx.navigateTo({
      url: '/pages/city/city',
    })
  },
  myIsDefault(e){
    // console.log(e);
    let index =e.currentTarget.dataset.index
  }
})